/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * <p>Project: javaseapp - MyDemo
 * <p>Powered by webrx On 2021-08-30 10:08:21
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class MyDemo {
    @Target(METHOD)
    @Retention(RUNTIME)
    public @interface FileTypes {
        FileType[] value();
    }

    @Target(METHOD)
    @Retention(RUNTIME)
    @Repeatable(FileTypes.class)
    public @interface FileType {
        String value() default ".class";
    }

    @FileType(".java")
    @FileType(".html")
    @FileType(".css")
    @FileType(".js")
    @FileType
    public void work() {

        try {
            FileType[] fileTypes = this.getClass().getMethod("work").getAnnotationsByType(FileType.class);
            System.out.println("将从如下后缀名的文件中查找文件内容");
            for (FileType fileType : fileTypes) {
                System.out.println(fileType.value());
            }
            System.out.println("查找过程略。。。");
        } catch (NoSuchMethodException | SecurityException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new MyDemo().work();
    }
}
